﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace ConexionBD
{
    public partial class FormAgrNot : Form
    {
        MySqlConnection Conexion = new MySqlConnection();
        public string stConsulta;
        string opcion1;
        string titulo;
        string contenido;
        string id_nota;
        int gogo;
        int valor1;

        public FormAgrNot()
        {
            InitializeComponent();
        }

        private void FormAgrNot_Load(object sender, EventArgs e)
        {
            Nota nan = new Nota();
           
            DataTable dt = new DataTable();
            dt = nan.agrNota();
            
            try
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                    comboBox1.Items.Add(dt.Rows[i]["id_libreta"]);
            }

            catch (MySqlException error)
            {
                throw error;
            }


 }
       
        private void button1_Click(object sender, EventArgs e)
        {
            Nota notilla = new Nota();
            
            Object selectedItem = comboBox1.SelectedItem;
           


            opcion1 = selectedItem.ToString();
            valor1 = Convert.ToInt32(opcion1);
            titulo = "'" + textBox1.Text + "'";
            contenido = "'" + richTextBox1.Text + "'";
            id_nota = textBox2.Text;
            int valor2 = valor1;
            notilla.enviarAgregarNota(valor2, id_nota, titulo, contenido);
            
            
            
        }
   
    }
}
